module ExpensesHelper
  def display_errors(expense)
    page.alert "The Expense could not be added for the following reasons:\n" +
      expense.errors.full_messages.join("\n")
  end
  def update_summary(project)
    page.replace 'summary', :partial => 'summary',
      :locals => { :min => project.min_expense,
      :max => project.max_expense,
      :avg => project.avg_expense }
  end
  def insert_expense(expense)
    page.insert_html :bottom, 'expenses', :partial => 'expense', :object => expense
    page.visual_effect :highlight, "expense-#{expense.id}"
  end
  def update_total(amount)
    page.replace_html 'total-amount', amount
  end
end
